package com.sisyphus.spinach.network.task;



import com.sisyphus.spinach.core.INetTask;
import com.sisyphus.spinach.core.model.IResponse;
import com.sisyphus.spinach.network.ResponseObserver;
import com.sisyphus.spinach.network.utils.RxUtil;

import io.reactivex.rxjava3.core.Observable;

/**
 * 简单网络任务
 */
public class NetSingleTask<T, V extends INetTask.View<T>> extends NetLifecycleTask<T, V> {

    private final Observable<? extends IResponse<T>> mObservable;

    public NetSingleTask(Observable<? extends IResponse<T>> observable) {
        mObservable = observable;
        //lifecycle.addObserver(this);
    }

    @Override
    public void execute() {
        mObservable.compose(RxUtil.transformer()).subscribe(new ResponseObserver<>(mView, this));
    }

}
